package api

import (
	"github.com/gin-gonic/gin"
	"golang-websocket-chatroom/api/hander"
	"golang-websocket-chatroom/constss"
	"golang-websocket-chatroom/pkg"
)

func LoadRouter(r *gin.Engine) {
	api := r.Group("./api")
	{
		user := api.Group("./user")
		{
			user.POST("./login", hander.Login)
		}
		room := api.Group("./room")
		{
			room.Use(pkg.JWTAuth(constss.JWT_SECRET_KEY))
			room.POST("./addRoom", hander.AddRoom)
			room.POST("./addRoomUser", hander.AddRoomUser)
			room.POST("./loginRoom", hander.LoginRoom)
			room.POST("./addChat", hander.AddChat)
			room.POST("./selectChat", hander.SelectChat)
			room.POST("./selectRoom", hander.SelectHistory)
		}
		chat := api.Group("./chat")
		{
			chat.Use(pkg.JWTAuth(constss.JWT_SECRET_KEY))
			chat.GET("./ws", hander.Ws)
		}
	}
}
